package com.wenbai.servicelightluxurystickers.controller;

import com.wenbai.servicelightluxurystickers.entity.StickCategory;
import com.wenbai.servicelightluxurystickers.service.StickCategoryService;
import com.wenbai.servicelightluxurystickers.utils.Response;
import lombok.Data;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/stick/category")
public class StickCategoryController {
    @Autowired
    private StickCategoryService stickCategoryService;


    /**
     * 新增类别
     * @param stickCategory
     * @return
     */
    @PostMapping
    public Response<String> save(@RequestBody StickCategory stickCategory){
        stickCategoryService.save(stickCategory);
        return Response.success("新增类别成功");
    }

    /**
     * 删除类别
     * @param id
     * @return
     */
    @DeleteMapping
    public Response<String> delete(String id){
        stickCategoryService.deldte(id);
        return Response.success("删除类别成功");
    }

    /**
     * 修改类别信息
     * @param stickCategory
     * @return
     */
    @PutMapping
    public Response<String> update(@RequestBody StickCategory stickCategory){
        stickCategoryService.update(stickCategory);
        return Response.success("修改类别成功");
    }


    @GetMapping("/select")
    public Response<List<StickCategory>> select() {
        return Response.success(stickCategoryService.selectCategory());
    }
}
